package com.businessTest;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

import com.beans.Movie;
import com.beans.Person;
import com.bussiness.AdminBussiness;
import com.utility.DBConnection;



public class AdminBusinessTest{

	public AdminBusinessTest()
	{
		super();
		System.out.println("i can execute");
	}

	
	@Test
	public void getAllSimpleMember() throws Exception
	{
		DBConnection dbcon = new DBConnection();

		Person[] allMemberList=null;
		String simple="S";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllSimpleMembers();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(simple,allMemberList[0].getCustomerType());	
	}
	
	@Test
	public void getAllPremiumMember() throws Exception
	{
		
		Person[] allMemberList=null;
		String premium="P";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllPremiumMembers();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(premium,allMemberList[0].getCustomerType());
	
	}

	@Test
	public void getAllMembersByState() throws Exception
	{
		
		Person[] allMemberList=null;
		String state="CA";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllMembersByState(state);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(state,allMemberList[0].getState());
	
	}
	
	
@Test
	
	public void getAllMembersByState_1() throws Exception
	{
		
		Person[] allMemberList=null;
		String state="sa";
		
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllMembersByState(state);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	

		int length=allMemberList.length;	
		
		Assert.assertEquals(0,length);
		
	}
	

	@Test
	public void getAllMembersByCity() throws Exception
	{
		
		Person[] allMemberList=null;
		String city="San Jose";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllMembersByCity(city);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(city,allMemberList[0].getCity());
	}
	

	@Test
	public void getAllMembersByCity_1() throws Exception
	{
		
		Person[] allMemberList=null;
		String city="1213";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllMembersByCity(city);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		int length=allMemberList.length;
	
		Assert.assertEquals(0,length);
	}

	@Test
	public void getAllMembersByZip() throws Exception
	{
		
		Person[] allMemberList=null;
		int zip=95035;
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllMembersByZip(zip);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(zip,allMemberList[0].getZipCode());
	}

	@Test
	public void getAllMembersByZip_1() throws Exception
	{
		
		Person[] allMemberList=null;
		int zip=95;
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllMembersByZip(zip);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		int length=allMemberList.length;
	
		Assert.assertEquals(0,length);
	}

	
	@Test
	public void getAllMembersByFname() throws Exception
	{
		
		Person[] allMemberList=null;
		String fname="Guest";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllMembersByFname(fname);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
	
		Assert.assertEquals(fname,allMemberList[0].getFirstName());
	}

	

	@Test
	public void getAllMembersByFname_1() throws Exception
	{
		
		Person[] allMemberList=null;
		String fname="Rud@#@";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllMembersByFname(fname);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		int length=allMemberList.length;
		
		Assert.assertEquals(0,length);
	}

	
	
@Test
	public void getAllMembersByLname() throws Exception
	{
		
		Person[] allMemberList=null;
		String lname="User";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			allMemberList=AdminBI.getAllMembersByLname(lname);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(lname,allMemberList[0].getLastName());
	}





@Test
public void getAllMembersByLname_1() throws Exception
   {
	
	Person[] allMemberList=null;
	String lname="Ashley34";
	
	AdminBussiness AdminBI=new AdminBussiness();
	//AdminBI.getAllMembers(state);
	
	
	try
	{
		allMemberList=AdminBI.getAllMembersByLname(lname);
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	int length=allMemberList.length;

	Assert.assertEquals(0,length);
 }


@Test
public void getPersonsById() throws Exception
   {
	
	Person allMemberList=null;
	long memid=1;
	
	AdminBussiness AdminBI=new AdminBussiness();
	//AdminBI.getAllMembers(state);
	
	
	try
	{
		allMemberList=AdminBI.getPersonsById(memid);
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}

	Assert.assertEquals(memid,allMemberList.getMemberShipNumber());
 }

@Test
public void getPersonsById_1() throws Exception
   {
	
	Person allMemberList=null;
	long memid=2;
	
	AdminBussiness AdminBI=new AdminBussiness();	
	
	try
	{
		allMemberList=AdminBI.getPersonsById(memid);
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}

	Assert.assertEquals(null,allMemberList);
 }
/*
	@Test
	public void getMovieByName() throws Exception
	{
		
		Movie movie=new Movie();
		String name="Immortals";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			movie=AdminBI.getMovieByName(name);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(name,movie.getMovieName());
		
		
		
		
	}
	

	@Test
	public void getMovieByBanner() throws Exception
	{
		
		Movie movie=new Movie();
	String banner="Dir: Tarsem Singh With: Henry";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			movie=AdminBI.getMovieByBanner(banner);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(banner,movie.getMovieBanner());
	}
	
	@Test
	public void getMovieByReleaseDate() throws Exception
	{
		
		Movie[] movie=null;
		String date="2011-10-06";
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			movie=AdminBI.getMovieByReleaseDate(date);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(date,movie[0].getReleaseDate());
	}
*/

	@Test
	public void getMovieByRent() throws Exception
	{
		
		Movie[] movie=null;
		double rent=10;
		int movieid=1;
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			movie=AdminBI.getMovieByRent(rent);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(movieid,movie[0].getMovieId());
		
	}
	
	@Test
	public void getMovieByReleasedate() throws Exception
	{
		
		Movie[] movie=null;
		String releasedate = "2011";
		int movieid=1;
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			movie=AdminBI.getMovieByReleaseDate(releasedate);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(movieid,movie[0].getMovieId());
		
	}
	
	@Test
	public void getMovieByCategory() throws Exception
	{
		
		Movie[] movie=null;
		String category = "Comedy";
		int movieid=1;
		
		AdminBussiness AdminBI=new AdminBussiness();
		//AdminBI.getAllMembers(state);
		
		
		try
		{
			movie=AdminBI.getMovieByCategory(category);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	
		Assert.assertEquals(movieid,movie[0].getMovieId());
		
	}
 }


